package com.tools.sqlmaker.make.impl;


import com.tools.sqlmaker.entry.OrgInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 默认rabbitmq对端队列管理器只有一个
 * @author: zhoubin
 * @date: 2023/9/7
 */
public class RabbitMqConfMaker extends MqConfMaker {

    public RabbitMqConfMaker(OrgInfo info) {
        super(info);
    }

    @Override
    public List<Map<String, Object>> getParamList() {
        OrgInfo info = getOrgInfo();
        List<String> sysQmCodeList = getSysQmCodeList();
        List<Map<String, Object>> paramList = new ArrayList<>();

        String[] exchangeList = info.getExchange();
        for (String sysQmCode : sysQmCodeList) {
            char qmCodeNum = sysQmCode.charAt(sysQmCode.length() - 1);

            for (int i = 0; i < exchangeList.length; i++) {
                char qmNum = (char) (65 + i);
                Map<String, Object> msgMap = makeDefaultMap();
                msgMap.put("qm_code", sysQmCode);
                msgMap.put("queue_code", "MSG_" + getQmCodePre() + qmNum + "_" + qmCodeNum);
                msgMap.put("queue_name", "MSG_TO_" + info.getOrgBic() + qmNum);
                msgMap.put("queue_dtl_type", "MSG");
                msgMap.put("remote_qm_code", getQmCodePre() + "A");
                msgMap.put("remote_node_code", getNodeCode());
                msgMap.put("ext_param", "{\"exchange\":\"" + exchangeList[i] + "\"}");
                paramList.add(msgMap);
            }
        }

        return paramList;
    }
}
